package com.zjitc.chapter05.mapper;

import com.zjitc.chapter05.domain.Order;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface OrderMapper {
    @Select("select * from `order` where user_id = #{userId}")
    @Results({
            @Result(id = true, property = "id", column = "id"),
    })
    List<Order> selectOrderListByUserId(Integer userId);
    @Select("select * from `order` where id = #{id}")
    @Results({
            @Result(id = true, property = "id", column = "id"),
            @Result(property = "products", column = "id", many = @Many(select = "com.zjitc.chapter05.mapper.ProductMapper.selectProductsByOrderId"))
    })
    Order selectOrderById(Integer id);
}
